package com.itheima.ydd.controller;


import com.itheima.ydd.common.R;
import com.itheima.ydd.common.ResultData;
import com.itheima.ydd.entity.YddUser;
import com.itheima.ydd.service.impl.YddUserServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2022-05-22
 */
@RestController
@RequestMapping("/ydd_user")
@Slf4j
public class YddUserController {

    @Autowired
    private YddUserServiceImpl yddUserService;

    @GetMapping("/list")
    public ResultData pageList(String sex, String username, String mobile, String page, String limit) {

        return yddUserService.pageList(sex, username, mobile, page, limit);
    }

    @GetMapping("/del")
    public ResultData delById(String id){
        yddUserService.delById(id);
        return ResultData.ok("删除成功",null);
    }
    @PostMapping("/add")
    public ResultData save(@RequestBody YddUser yddUser){
        yddUserService.addUser(yddUser);
        return ResultData.ok("");
    }
    @PostMapping("/update")
    public ResultData update(@RequestBody YddUser yddUser){
        yddUserService.update(yddUser);
        return ResultData.ok("修改成功",null);
    }
    @GetMapping("/rowInfo")
    public ResultData rowInfo(String id){
        log.info("",id);
        YddUser yddUser = yddUserService.rowInfo(id);
        return ResultData.ok("查询成功",yddUser);
    }
}
